<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>消费记录</title>
    <link rel="stylesheet" href="../../js/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/common.css" media="all">
    <script src="../../js/layui/layui.all.js"></script>
    <script src="../../js/config.js"></script>
    <script src="../../js/token.js"></script>
</head>
<body>
<blockquote class="layui-elem-quote quoteBox mod_default_box">
    <form class="layui-form">
        <div class="layui-form-inline">
            <label class="layui-form-label">消费日期</label>
            <div class="layui-input-inline">
                <input type="text" id="start_time" name="start_time" autocomplete="off" placeholder="请输入开始时间" class="layui-input">
            </div> 至
            <div class="layui-input-inline">
                <input type="text" id="end_time" name="end_time" autocomplete="off" placeholder="请输入结束时间" class="layui-input">
            </div>

            <div class="layui-input-inline" style="padding-left: 50px;">
                <input type="text" name="staffName" style="width: 190px" placeholder="请输入关键字" autocomplete="off" class="layui-input" />
            </div>
            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search-xf-submit">
                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
        </div>
    </form>
</blockquote>

<!--数据列表-->
<div class="layui-card-body">
    <table class="layui-hide" id="test" lay-filter="xf-table"></table>
</div>
</body>
<script type="text/html" id="tb">
    <div class="layui-container" style="margin-left:0px;">
<!--        <a class="layui-btn layui-btn-xs" id="exportExcel">导出Excel</a>-->
    </div>
</script>
<script>
    layui.use(['table'], function() {
        var $ = layui.$;
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;
        table.render({
            elem: '#test',
            id: 'tt',
            url: HOST+'xf/getXfRecord',
            toolbar: '#tb',
            cols: [
                [{
                    field: 'id',
                    title: '序号',
                    type: 'numbers',
                    align: 'center'
                },
                {
                    field: 'staffBh',
                    title: '编号',
                    width : '10%',
                    align: 'center'
                },
                {
                    field: 'staffName',
                    title: '姓名',
                    width: '10%',
                    align: 'center'
                },
                {
                    field: 'staffPhone',
                    title: '联系方式',
                    width : '15%',
                    align: 'center'
                },
                {
                    field: 'cardNo',
                    title: '会员卡号',
                    width : '15%',
                    align: 'center'
                },
                {
                    field: 'xfAmount',
                    title: '消费金额',
                    width : '10%',
                    align: 'center'
                },
                {
                    field: 'xfTime',
                    title: '消费时间',
                    width: '15%',
                    align: 'center'
                }]
            ], page: true
            ,page: {
                curr: layui.data("xf_page").index
            },
            done: (res, curr, count) => {
                layui.data("xf_page", {
                    key: 'index',
                    value: curr
                });
                // bindClick();
            }
        });

        //搜索操作
        form.on('submit(search-xf-submit)', function (data) {
            table.reload('tt', {
                where: {"staffName": data.field.staffName,"start_time":data.field.start_time,"end_time":data.field.end_time }
                , page: {
                    curr: 1
                }
            });
            return false;
        });
        function bindClick() {
            $('#exportExcel').on('click',function () {
                var staffName = $("#staffName").val();
                var start_time = $("#start_time").val();
                var end_time = $("#end_time").val();
                $("#exportExcel").attr('href',"/xf/exportExcelByXf?staffName=" + staffName + "&start_time=" + start_time + "&end_time=" + end_time);
                console.log($("#exportExcel").attr('href'));
            });
        }
    });
</script>

<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        var endDate= laydate.render({
            elem: '#end_time',//选择器结束时间
            type: 'datetime',
            min:"1970-1-1",//设置min默认最小值
            done: function(value,date){
                startDate.config.max={
                    year:date.year,
                    month:date.month-1,//关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                }
            }
        });
        //日期范围
        var startDate=laydate.render({
            elem: '#start_time',
            type: 'datetime',
            max:"2099-12-31",//设置一个默认最大值
            done: function(value, date){
                endDate.config.min ={
                    year:date.year,
                    month:date.month-1, //关键
                    date: date.date,
                    hours: 0,
                    minutes: 0,
                    seconds : 0
                };
            }
        });
    });
</script>
</html>